package com.kanshu.ksgb.fastread.doudou.common.util;

import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;

import com.kanshu.ksgb.fastread.doudou.app.Xutils;

import me.drakeet.support.toast.ToastCompat;

/**
 * Toast util class.
 *
 * @author <a href="http://blog.csdn.net/arui319">http://blog.csdn.net/arui319</a>
 * @version 2011/11/30
 */
public class ToastUtil {

    private static Toast sToast;


    public static void showMessage(final Context act, final String msg) {
        //showMessage(act, msg, Toast.LENGTH_SHORT);
        showMessage(msg);
    }

    public static void showMessage(final Context act, final int msg) {
        //showMessage(act, msg, Toast.LENGTH_SHORT);
        showMessage(msg);
    }

    public static void showMessage(final String msg) {
        showMessage(Xutils.getContext(), msg, Toast.LENGTH_LONG);
    }

    public static void showMessage(final int msg) {
        showMessage(Xutils.getContext(), msg, Toast.LENGTH_SHORT);
    }

    public static void showMessage(final Context act, final String msg, final int len) {
        ToastCompat.makeText(act, msg, len).show();
    }


    public static void showMessage(final Context act, final int msg,
                                   final int len) {
        ToastCompat.makeText(act, msg, len).show();
    }

    public static void showStaticMessage(String s) {
        if (TextUtils.isEmpty(s)) {
            return;
        }
        if (sToast == null) {
            sToast = ToastCompat.makeText(Xutils.getContext(), s, Toast.LENGTH_SHORT);
        }
        if (sToast != null) {
            sToast.setText(s);
            sToast.show();
        }
    }

    public static void cancelStaticToast() {
        if (sToast != null) {
            sToast.cancel();
        }
    }

}  